<?php
namespace Home\Controller;
use Think\Controller;
use Home\Model\RolePermissionModel;

class TestController extends Controller {
    public function test(){
		// $id = isset($_POST['id']) ? $_POST['id'] : 0;
		// 	$query = mysql_query("SELECT id,permission_name,status,url FROM t_permission where id = 1");
		
		// $json = '';
		// while (!!$row = mysql_fetch_array($query, MYSQL_ASSOC)) {
		// 	$json .= json_encode($row).',';
		// }

		// $json = substr($json, 0, -1);
		// echo '['.$json.']';
		// mysql_close();
    	dump("hahhah");exit;
		$a = D("Permission")->field("id,permission_name,status,url")->where(array("id"=>1))->select();
		dump($a);exit();
    }

    public function data(){
		session('test_data',11111);
		echo json_encode(['data'=>'success']);
    }


    public function aa()
	{
		echo json_encode(['data'=>session('test_data')]);
	}

	public function bb()
	{
		session(null);
		echo json_encode(['data'=>session('test_data')]);
	}

	public function testdownload()
	{
		$program_id = I("get.program_id","");
		$res = D("ProgramDownload")->get_movieurl($program_id);
	}

	public function goto()
	{
		$sql = "SELECT id FROM movie WHERE program_id IN (SELECT id FROM t_program WHERE type = 3)";
		$model = M();
		$res = $model->query($sql);
		foreach ($res as $key => $value) {
			$movie_id = $value['id'];
			$data['province_id'] = 20;
			$data['movie_id'] = $movie_id;
			$data['download_status'] = -3;
			$data['create_time'] = time(); 
			$data['update_time'] = time(); 
			M("TDownload")->add($data);
		}
	}

}